﻿Public Class frmSuaHoSoHocSinh

    Public MaHS As Integer
    Public MaLop As Integer = -1

    Private Sub frmSuaHoSoHocSinh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds As New List(Of LopDTO)
        Dim hsBUS As New LopBUS()
        ds = LopBUS.SelectAll()

        cboLop.DataSource = ds
        cboLop.ValueMember = "MALOP"
        cboLop.DisplayMember = "TENLOP"

        If MaLop > -1 Then
            cboLop.SelectedValue = MaLop
        End If
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
            Dim hsDTO As New HocSinhDTO()
            'Dim hsDTO = New HocSinhDTO
            hsDTO.MAHOCSINH = MaHS
            hsDTO.TENHOCSINH = txtTenHS.Text
            If (rbNam.Checked) Then
                hsDTO.GIOITINH = "Nam"
            Else
                hsDTO.GIOITINH = "Nữ"
            End If
            hsDTO.NGAYSINH = txtNgaySinh.Text
            'hsDTO.cmnd = txtCMND.Text
            'hsDTO.NGAYSINH = dtpNgaySinh.Value
            hsDTO.DIACHI = txtDiaChi.Text
            hsDTO.SODT = txtSoDT.Text
            hsDTO.EMAIL = txtEmail.Text
            hsDTO.MALOP = cboLop.SelectedValue

            Dim hsBUS As New HocSinhBUS()
            Dim res = HocSinhBUS.SuaKhachHang(hsDTO)
            If res >= 0 Then
                MessageBox.Show("Sửa thành công")
            Else
                MessageBox.Show("Sửa thất bại")
            End If
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtMaHS.Text = String.Empty
        txtTenHS.Text = String.Empty
        rbNam.Checked = True
        txtNgaySinh.Text = String.Empty
        txtDiaChi.Text = String.Empty
        txtEmail.Text = String.Empty
        txtSoDT.Text = String.Empty
    End Sub

  
End Class